package com.itmuch.cloud.study;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;

/**
 * @author 邓志渊
 * @version 1.0
 * @time 2019/11/1 9:43
 * @describe
 */
public class Test1 {

    public static void main(String[] args) throws Exception {
        String base = "E:\\code\\";
        File file = new File(base);
        File[] files = file.listFiles();
        for (int i = 0; i < files.length; i++) {
            System.out.println(files[i].getName());
        }
        String fileName = "1234656.txt";
        File newfile = new File(base+fileName);
        if(!newfile.exists()){
            newfile.createNewFile();
        }
        FileOutputStream fos  = new FileOutputStream(newfile);
        for(int i=0;i<2;i++){
            String con = "这是第"+i+"行:前面介绍的各种方法都不关用,为什么总是奇怪的问题";
            fos.write(con.getBytes("utf-8"));
        }
        fos.close();
        System.out.println("成功");
    }
}
